package com.project.personnel.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.personnel.dao.PositionMapper;
import com.project.personnel.entity.Position;
import com.project.personnel.service.PositionService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author diaominyh
 * @since 2022-12-12
 */
@RestController
@RequestMapping("/position")
public class PositionController {
    @Resource
    private PositionService positionService;
    @Resource
    private PositionMapper positionMapper;
    @GetMapping("/positionCha")
    //查询职位管理
    public List<Position> positionCha(){
        return positionService.list();
    }
    @PostMapping("/positionAdd")
    //添加职位管理
    public boolean positionAdd(@RequestBody Position position){
        return positionService.save(position);
    }
    @DeleteMapping("/positionDelete/{id}")
    //删除职位管理
    public int positionDelete(@PathVariable Integer id){
        QueryWrapper<Position> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("id",id);
        return positionMapper.delete(queryWrapper);
    }
    @PutMapping("/positionUpdate")
    //修改职位管理
    public boolean positionUpdate(@RequestBody Position position){
        return positionService.updateById(position);
    }
    //批量删除
    @DeleteMapping("/deleteposition")
    public boolean deletePosition(@RequestParam("id") List<Integer> id){
        return positionService.removeByIds(id);
    }

}

